<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>舌头状态检测系统</title>
    <style>
        body {
            font-family: 'Microsoft YaHei', sans-serif;
            background-color: #f5f5f5;
            margin: 0;
            padding: 0;
            display: flex;
            justify-content: center;
            align-items: center;
            min-height: 100vh;
        }
        .container {
            background-color: #fff;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
            padding: 30px;
            width: 100%;
            max-width: 500px;
            text-align: center;
            position: relative;
        }
        h1 {
            color: #333;
            margin-bottom: 20px;
        }
        .upload-form {
            margin-top: 20px;
        }
        .file-input-wrapper {
            position: relative;
            overflow: hidden;
            display: inline-block;
            margin-bottom: 20px;
        }
        .file-input {
            position: absolute;
            font-size: 100px;
            opacity: 0;
            right: 0;
            top: 0;
            cursor: pointer;
        }
        .file-input-button {
            background-color: #4CAF50;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            display: inline-block;
        }
        .submit-button {
            background-color: #2196F3;
            color: white;
            padding: 10px 20px;
            border: none;
            border-radius: 4px;
            cursor: pointer;
            margin-top: 10px;
        }
        .submit-button:hover, .file-input-button:hover {
            opacity: 0.9;
        }
        .preview-container {
            margin-top: 20px;
            display: none;
        }
        .preview-image {
            max-width: 100%;
            max-height: 300px;
            border-radius: 4px;
        }
        .flash-messages {
            margin-bottom: 20px;
        }
        .flash-message {
            padding: 10px;
            background-color: #f8d7da;
            color: #721c24;
            border-radius: 4px;
            margin-bottom: 10px;
        }
        /* 加载遮罩层样式 */
        .loading-overlay {
            display: none;
            position: fixed;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
            background-color: rgba(0, 0, 0, 0.7);
            z-index: 1000;
            justify-content: center;
            align-items: center;
            flex-direction: column;
        }
        .loading-spinner {
            border: 6px solid #f3f3f3;
            border-top: 6px solid #3498db;
            border-radius: 50%;
            width: 50px;
            height: 50px;
            animation: spin 2s linear infinite;
            margin-bottom: 20px;
        }
        .loading-text {
            color: white;
            font-size: 18px;
            text-align: center;
        }
        @keyframes spin {
            0% { transform: rotate(0deg); }
            100% { transform: rotate(360deg); }
        }
        /* 添加导航栏样式 */
        .nav {
            display: flex;
            justify-content: center;
            gap: 20px;
            margin-bottom: 30px;
        }
        
        .nav a {
            padding: 8px 15px;
            background-color: #3498db;
            color: white;
            text-decoration: none;
            border-radius: 20px;
            font-weight: bold;
            transition: all 0.3s ease;
        }
        
        .nav a:hover {
            background-color: #2980b9;
            transform: translateY(-2px);
            box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
        }
    </style>
</head>
<body>
    <!-- 加载遮罩层 -->
    <div id="loading-overlay" class="loading-overlay">
        <div class="loading-spinner"></div>
        <div class="loading-text">正在分析舌头图片，请稍候...</div>
        <div class="loading-text" style="margin-top: 10px; font-size: 14px;">分析需要5-15秒，请勿关闭页面</div>
    </div>
    
    <div class="container">
        <h1>智能舌诊系统</h1>
        
        <div class="nav">
            <a href="#upload-section">舌诊分析</a>
            <a href="{{ skeleton_url }}">骨骼健康评估</a>
        </div>
        
        <p>请上传您的舌头图片，系统将为您分析舌头状态。</p>
        
        <div class="flash-messages">
            {% with messages = get_flashed_messages() %}
                {% if messages %}
                    {% for message in messages %}
                        <div class="flash-message">{{ message }}</div>
                    {% endfor %}
                {% endif %}
            {% endwith %}
        </div>
        
        <form id="upload-form" class="upload-form" action="/upload" method="post" enctype="multipart/form-data">
            <div class="file-input-wrapper">
                <button type="button" class="file-input-button">选择图片</button>
                <input type="file" name="file" id="file-input" class="file-input" accept="image/*">
            </div>
            
            <div class="preview-container" id="preview-container">
                <img id="preview-image" class="preview-image" src="#" alt="预览图像">
            </div>
            
            <div class="gender-selection" style="margin: 15px 0;">
                <label style="margin-right: 10px;">
                    <input type="radio" name="gender" value="男" checked> 男
                </label>
                <label>
                    <input type="radio" name="gender" value="女"> 女
                </label>
            </div>
            
            <button type="submit" class="submit-button">上传并分析</button>
        </form>
    </div>
    
    <script>
        document.getElementById('file-input').addEventListener('change', function(event) {
            const file = event.target.files[0];
            if (file) {
                const reader = new FileReader();
                reader.onload = function(e) {
                    const previewContainer = document.getElementById('preview-container');
                    const previewImage = document.getElementById('preview-image');
                    previewImage.src = e.target.result;
                    previewContainer.style.display = 'block';
                };
                reader.readAsDataURL(file);
            }
        });
        
        // 添加表单提交事件监听
        document.getElementById('upload-form').addEventListener('submit', function(e) {
            // 检查是否选择了文件
            const fileInput = document.getElementById('file-input');
            if (fileInput.files.length === 0) {
                return; // 如果没有选择文件，不显示加载界面
            }
            
            // 显示加载遮罩层
            const loadingOverlay = document.getElementById('loading-overlay');
            loadingOverlay.style.display = 'flex';
            
            // 允许表单提交继续进行
            // 表单提交后页面会重定向到结果页面
        });
    </script>
</body>
</html> 